﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PayrollHR.Web;
using Payroll.BusinessLogic.CustomerManager;
using Payroll.Common.Utils;
namespace PayrollHR.Administration.Modules
{
    public partial class addCustomerType : BasePayrollAdministrationUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
               if(CommonHelper.IsNull(save()))
               {
                   lblCustomertype.Visible = true;
               }
                else
               {
                   Response.Redirect("ListCustomerType.aspx");
               }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
        private CutomerType save()
        {

            var CustomerTypeInfo = CustomerTypeInfo1.getCustomerTypeInfo();
            if (CustomerTypeInfo.CutomerTypeName.Length == 0)
            {
                return null;
            }
            this.CustomerService.SaveCutomerType(CustomerTypeInfo);
            return CustomerTypeInfo;
        }

        protected void SaveAndStayButton_Click(object sender, EventArgs e)
        {
            try
            {
                save();
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
    }
}